<?php
namespace app\mobile\controller;

use think\Controller;
use think\Request;
use app\admin\model\Quote as QuoteModel;

class Quote extends Base
{
    protected $model;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->model = new QuoteModel();
    }

    public function index($source = 1)
    {
        if (Request::instance()->isAjax()) {
            $district = intval(input('post.did'));
            $acreage = intval(input('post.acreage'));
            $username = input('post.username');
            $telphone = input('post.telphone');
            $time = time();

            try {
                $this->model->save([
                    'source' => $source,
                    'district' => $district,
                    'acreage' => $acreage,
                    'username' => $username,
                    'telphone' => $telphone,
                    'time' => $time,
                ]);
            } catch (\Exception $e) {
                $msg = $e->getMessage();
           
                $this->error("错误代码:".$msg);
            }
                return ['code' => 2, 'msg'=>'报价成功'];
        }
        return $this->fetch();
    }
}
